# Maintainer:  Jürgen Hötzel <juergen@archlinux.org>
pkgname=ocaml-topkg
pkgver=1.0.3
pkgrel=2
pkgdesc="A packager for distributing OCaml software"
arch=('x86_64')
url="https://erratique.ch/software/topkg"
license=('BSD')
depends=('ocaml>=4.12.0' 'ocaml-result')
makedepends=('ocaml-findlib' 'ocamlbuild' 'opam' 'ocaml-compiler-libs')
source=("https://erratique.ch/software/topkg/releases/topkg-${pkgver}.tbz")
sha512sums=('7e9fe1ee00f358496a73ef09aa3b10576701e29c81e9ab7d340982718e7fdad4e66d670a3ee98f83315e3eebd8553144c75c3d17ca4054202adb3acae8699dee')


build() {
  cd "${srcdir}/topkg-${pkgver}"

  pkg/pkg.ml build --pkg-name topkg
}

package() {
  cd "${srcdir}/topkg-${pkgver}"

  opam-installer --prefix="${pkgdir}/usr" \
    --libdir="${pkgdir}$(ocamlc -where)" \
    --docdir="${pkgdir}/usr/share/doc"
  install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}"
  mv "${pkgdir}/usr/share/doc/topkg/LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.md"
}
